package com.alibaba.datax.elasticresource.handler;

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import org.apache.flink.runtime.rest.messages.ResponseBody;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.flink.util.Preconditions;

import com.alibaba.datax.core.statistics.SummaryStatistics;
import com.leehom.arch.datax.report.core.model.ReportLog;

/**
 * @类名: DataxStatisticsReportResult
 * @说明: 统计报告返回
 *
 * @author   leehom
 * @Date	 2024年8月26日 下午9:49:12
 * 修改记录：
 *
 * @see 	 
 */
public class DataxStatisticsReportResult implements ResponseBody, Serializable {

    private static final long serialVersionUID = 6021307225771402569L;

	public static final String FIELD_NAME_REPORTERS = "reports";

    @JsonProperty(FIELD_NAME_REPORTERS)
    private final Collection<ReportLog<SummaryStatistics>> reports;

    @JsonCreator
    public DataxStatisticsReportResult(
    		@JsonProperty(FIELD_NAME_REPORTERS) List<ReportLog<SummaryStatistics>> reports) {
        this.reports = Preconditions.checkNotNull(reports);
    }

    public Collection<ReportLog<SummaryStatistics>> getReports() {
        return reports;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        DataxStatisticsReportResult that = (DataxStatisticsReportResult) o;
        return Objects.equals(reports, that.reports);
    }

    @Override
    public int hashCode() {
        return Objects.hash(reports);
    }

    public static DataxStatisticsReportResult empty() {
        return new DataxStatisticsReportResult(Collections.emptyList());
    }
}
